package AcWing练习题;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: a
 * Date: 2022-08-15
 * Time: 10:39
 */
public class Demo_4405 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int k = scanner.nextInt();
        int[][] array = new int[n+1][m+1];
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= m; j++){
                array[i][j] = scanner.nextInt() + array[i-1][j];
            }
        }
        long ret = 0;
        for(int i = 1; i <= n; i++){
            for(int j = i; j <= n; j++){
                int left = 1;
                int right = 1;
                int sum = 0;
                for(;right <= m; right++){
                    sum += array[j][right] - array[i-1][right];
                    while(sum > k){
                        sum -= array[j][left] - array[i-1][left];
                        left++;
                    }
                    ret += right - left + 1;
                }
            }
        }
        System.out.println(ret);
    }
}
